home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / WMS.CAB / controlprotocoladmin.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  19.9 KB  |  600 lines

  1. ∩╗┐<%@ Language=VBScript CODEPAGE=65001 %>
  2. <!--#include file="include/wmsLocStrings.inc"-->
  3. <!--#include file="include/wmsServerHash.inc"-->
  4. <!--#include file="include/wmsPlugins.inc"-->
  5. <!--#include file="include/wmsHeader.inc"-->
  6. <!--#include file="include/wmsPageBanner.inc"-->
  7. <!--#include file="include/wmsError.inc"-->
  8. <%
  9. '+-------------------------------------------------------------------------
  10. '
  11. '  Microsoft Windows Media
  12. '  Copyright (C) Microsoft Corporation. All rights reserved.
  13. '
  14. '  File:       ControlProtocolAdmin.asp
  15. '
  16. '  Contents:
  17. '
  18. '--------------------------------------------------------------------------
  19.  
  20. ConnectToPlugin
  21. ConnectToPluginAdmin
  22.  
  23. BeginErrorHandling
  24.  
  25. Dim bDebugAllowAll
  26. Dim bDebugUseDefaultIP
  27. Dim szProtocolName
  28. Dim dwDefaultPort
  29. Dim bUsesDefaultPort
  30. Dim dwTabIndex
  31. Dim rgBoundIPAddrs
  32. Dim rgAvailIPAddrs
  33. Dim rgLen
  34.  
  35. bDebugAllowAll = true
  36. bDebugUseDefaultIP = true
  37. dwTabIndex = 0
  38. bUsesDefaultPort = false
  39.     
  40. szProtocolName = g_objPluginAdmin.ControlProtocol
  41. if( "" <> szProtocolName ) then
  42.     if( 0 = StrComp( "MMS", szProtocolName, vbTextCompare ) ) then
  43.         dwDefaultPort = 1755
  44.     elseif( 0 = StrComp( "RTSP", szProtocolName, vbTextCompare ) ) then
  45.         dwDefaultPort = 554
  46.     elseif( 0 = StrComp( "HTTP", szProtocolName, vbTextCompare ) ) then
  47.         dwDefaultPort = 80
  48.     else
  49.         dwDefaultPort = 0
  50.     end if
  51. end if
  52.  
  53. Dim strOp
  54. strOp = trim( posting( "submit" ) )
  55. if( 0 < Len( strOp ) ) then
  56.     on error resume next
  57.         
  58.     Err.Clear
  59.     Session( "ErrorNumber" ) = 0
  60.  
  61.     Dim strPort
  62.     Dim dwPortNumber
  63.     strPort = CStr( trim ( posting( "Port" ) ) )
  64.     dwPortNumber = CDbl( trim( posting( "PortNumber" ) ) )
  65.  
  66.     err.number = 0
  67.     if( 0 = err.number ) then
  68.         if( 0 < Len( strPort ) ) then
  69.             if( ( 0 = StrComp( "Default", strPort, vbTextCompare ) ) or ( dwDefaultPort = dwPortNumber ) )then
  70.                 if( dwDefaultPort <> g_objPluginAdmin.port ) then
  71.                     g_objPluginAdmin.port = dwDefaultPort
  72.                 end if
  73.             else
  74.                 dwPortNumber = CDbl( posting( "portNumber" ) )
  75.                 if( 0 >= dwPortNumber ) or ( 65536 <= dwPortNumber )then
  76.                     Raise( -1 )
  77.                     err.description = RemoveDangerousCharacters( L_INVALIDPORTENTRY_TEXT )
  78.                 else
  79.                     
  80.                     if( g_objPluginAdmin.port <> dwPortNumber ) then
  81.                         if( ( 0 < dwPortNumber ) and ( 65535 >= dwPortNumber ) ) then
  82.                             g_objPluginAdmin.port = dwPortNumber
  83.                         end if
  84.                     end if
  85.                 end if
  86.             end if
  87.  
  88.             if ErrorDetected( "Port" ) then
  89.                 Raise( -1 )
  90.             end if
  91.         end if
  92.     end if
  93.     
  94.     if( "" <> posting("IPAddrMode") ) then
  95.         if( "listenSelected" = trim( posting("IPAddrMode") ) ) then
  96.  
  97.             bDebugAllowAll = false
  98.             if( g_objPluginAdmin.ListenAllIPAddresses ) then
  99.                 g_objPluginAdmin.ListenAllIPAddresses = FALSE
  100.             end if
  101.             
  102.             Dim newIP
  103.             Dim boundIPAddresses
  104.             Dim availIPAddresses
  105.             set boundIPAddresses = g_objPluginAdmin.BoundIPAddresses
  106.             set availIPAddresses = g_objServer.AvailableIPAddresses
  107.             boundIPAddresses.RemoveAll
  108.             for i = 0 to ( posting( "numIPAddrs" ) - 1 )
  109.                 qskey = CStr( "IPAddr" & i )
  110.  
  111.                 if( "" <> posting( CStr( qskey ) ) ) then
  112.                     newIP = availIPAddresses( i )
  113.                 end if
  114.                 if( "" <> newIP ) then
  115.                     boundIPAddresses.Add( newIP )
  116.                 end if
  117.  
  118.                 if ErrorDetected( "SelectedIP" ) then
  119.                     Raise( -1 )
  120.                     exit for
  121.                 end if
  122.                 
  123.             next
  124.             
  125.  
  126.         else
  127.             if( FALSE = g_objPluginAdmin.ListenAllIPAddresses ) then
  128.                 g_objPluginAdmin.ListenAllIPAddresses = TRUE
  129.             end if
  130.             
  131.             if ErrorDetected( "AllIP" ) then
  132.                 Raise( -1 )
  133.             end if
  134.  
  135.         end if
  136.         
  137.     end if
  138.  
  139.     if ( 0 = err.number ) then
  140.         if( FALSE = IsEmpty( g_objPubPoint ) ) then
  141.             Response.Redirect "../pubpoints/pubpoint_props.asp?server=" & g_strQueryStringServer & "&ppID=" & g_strPubPointID & "&category=" & g_strCategory & "&pluginIndex=" & qs("pluginIndex")
  142.         else
  143.             Response.Redirect "../server_props.asp?server=" & g_strQueryStringServer & "&category=" & g_strCategory & "&pluginIndex=" & qs("pluginIndex")
  144.         end if
  145.     end if
  146. else
  147.     bDebugAllowAll = g_objPluginAdmin.ListenAllIPAddresses
  148. end if
  149.                                 
  150. set rgBoundIPAddrs = g_objPluginAdmin.BoundIPAddresses
  151. set rgAvailIPAddrs = g_objServer.AvailableIPAddresses
  152. rgLen = rgAvailIPAddrs.Count
  153.  
  154. if ( CDbl( dwDefaultPort ) = CDbl( g_objPluginAdmin.port ) ) then
  155.     bUsesDefaultPort = true
  156. end if
  157.  
  158.  
  159. WriteHTMLHeader( g_strDecodedServerName ) 
  160. %>
  161. <link rel="stylesheet" type="text/css" href="<%= Session( "cssName" ) %>">
  162. <% WritePluginJSUtils %>
  163. <script language="javascript">
  164. <!--
  165. /*@cc_on @*/
  166.  
  167. var g_bUserAlertedToNaNEntry;
  168. var g_bUserAlertedToOutOfRangeEntry;
  169.  
  170. g_bUserAlertedToNaNEntry = false;
  171. g_bUserAlertedToOutOfRangeEntry = false;
  172.  
  173. ///////////////////////////////////////////////////////////////////////////
  174. function IsNaturalNumber( szValue )
  175. {
  176.     <% jsTRY %>
  177.     var dwNumber;
  178.     var szNumber = szValue;
  179.     var szConvertedNumber;
  180.     
  181.     var regExpTest = new RegExp( /^\d+$/gi );
  182.     if( ! regExpTest.test( szValue ) )
  183.     {
  184.         return( false );
  185.     }
  186.     return( true );
  187.     
  188.     <% jsCATCH %>
  189.     return( false );
  190. }
  191.  
  192. ///////////////////////////////////////////////////////////////////////////
  193. function IsValidPortNumber( szValue )
  194. {
  195.     <% jsTRY %>
  196.     if( ! IsNaturalNumber( szValue ) )
  197.     {
  198.         return( false );
  199.     }
  200.     
  201.     var dwNumber = new Number( szValue );
  202.     if( dwNumber > 65535 )
  203.     {
  204.         return( false );
  205.     }
  206.         
  207.     if( dwNumber <= 0 )
  208.     {
  209.         return( false );
  210.     }
  211.     
  212.     return( true );
  213.     <% jsCATCH %>
  214. }
  215.  
  216.  
  217. ///////////////////////////////////////////////////////////////////////////
  218. function CanEnableOkButton()
  219. {
  220.     <% jsTRY %>
  221.     if( true == document.forms.pluginForm.portNumber.disabled )
  222.     {
  223.         if( true == document.forms.pluginForm.Port[ 0 ].checked )
  224.         {
  225.             document.forms.pluginForm.ok.disabled = false;
  226.         }
  227.     }
  228.     <% jsCATCH %>
  229. }
  230.  
  231. ///////////////////////////////////////////////////////////////////////////
  232. function IsValidEntry()
  233. {
  234.     <% jsTRY %>
  235.     var dwPortNumber;
  236.     var szPortEntry;
  237.     var bValidNumber;
  238.     var bInRange;
  239.     
  240.     if( document.forms.pluginForm.Port[ 0 ].checked )
  241.     {
  242.         document.forms.pluginForm.ok.disabled = false;
  243.         return;
  244.     }
  245.     
  246.     if( document.forms.pluginForm.portNumber.disabled )
  247.     {
  248.         document.forms.pluginForm.ok.disabled = true;
  249.         return;
  250.     }
  251.  
  252.     szPortEntry = new String( document.forms.pluginForm.portNumber.value );
  253.     bValidNumber = true;
  254.     bInRange = true;
  255.     
  256.     if( 0 == szPortEntry.length )
  257.     {
  258.         document.forms.pluginForm.portNumber.style.color="#000000";
  259.         document.forms.pluginForm.ok.disabled = true;
  260.         return;
  261.     }
  262.     
  263.     if( ! IsNaturalNumber( szPortEntry ) )
  264.     {
  265.         bValidNumber = false;
  266.     }
  267.         
  268.     if( bValidNumber )
  269.     {
  270.         bInRange = IsValidPortNumber( szPortEntry );
  271.     }
  272.     
  273.     if( ! bValidNumber || ! bInRange )
  274.     {
  275.         document.forms.pluginForm.portNumber.style.color="#ff0000";
  276.         document.forms.pluginForm.ok.disabled = true;
  277.  
  278.         if( ! bValidNumber && ( false == g_bUserAlertedToNaNEntry ) )
  279.         {
  280.             g_bUserAlertedToNaNEntry = true;
  281.             window.alert( "<%= RemoveDangerousCharacters( L_INVALIDENTRY_TEXT ) %>" );
  282.         }
  283.         
  284.         if( ! bInRange && ( false == g_bUserAlertedToOutOfRangeEntry ) )
  285.         {
  286.             g_bUserAlertedToOutOfRangeEntry = true;
  287.             window.alert( "<%= RemoveDangerousCharacters( L_INVALIDPORTENTRY_TEXT ) %>" );
  288.         }
  289.         return;
  290.     }
  291.  
  292.     document.forms.pluginForm.portNumber.style.color="#000000";
  293.     document.forms.pluginForm.ok.disabled = false;
  294.     
  295.     CanEnableOkButton();
  296.     <% jsCATCH %>
  297. }
  298.  
  299. ///////////////////////////////////////////////////////////////////////////
  300. function TogglePortRadioButtons( dwWhichButton )
  301. {
  302.     <% jsTRY %>
  303.     if( 0 == dwWhichButton )
  304.     {
  305.         document.forms.pluginForm.Port[0].checked = true;
  306.         document.forms.pluginForm.Port[1].checked = false;
  307.         document.forms.pluginForm.portNumber.disabled = true;
  308.         CanEnableOkButton();
  309.     }
  310.     else
  311.     {
  312.         document.forms.pluginForm.Port[0].checked = false;
  313.         document.forms.pluginForm.Port[1].checked = true;
  314.         document.forms.pluginForm.portNumber.disabled = false;
  315.         IsValidEntry();
  316.     }
  317.     <% jsCATCH %>
  318. }
  319.  
  320. ///////////////////////////////////////////////////////////////////////////
  321. function AssignToOtherPort()
  322. {
  323.     <% jsTRY %>
  324.     var theForm;
  325.     var theElement;
  326.     theForm = document.forms.controlProtocol;
  327.     theElement = theForm.Port;
  328.  
  329.     document.forms.pluginForm.Port[0].checked = true;
  330.     document.forms.pluginForm.Port[1].checked = false;
  331.     document.forms.pluginForm.portNumber.value = "<%= dwDefaultPort %>";
  332.     return;
  333.     <% jsCATCH %>
  334. }
  335.  
  336. ///////////////////////////////////////////////////////////////////////////
  337. function ToggleIPAddressMode( dwWhichControl )
  338. {
  339.     <% jsTRY %>
  340.     if( 0 == dwWhichControl )
  341.     {
  342.         document.forms.pluginForm.IPAddrMode[ 0 ].checked = true;
  343.         document.forms.pluginForm.IPAddrMode[ 1 ].checked = false;
  344.     }
  345.     else
  346.     {
  347.         document.forms.pluginForm.IPAddrMode[ 0 ].checked = false;
  348.         document.forms.pluginForm.IPAddrMode[ 1 ].checked = true;
  349.     }
  350.     
  351.     SetControlStates();
  352.     <% jsCATCH %>
  353. }
  354.  
  355. ///////////////////////////////////////////////////////////////////////////
  356. function SetControlStates()
  357. {
  358.     <% jsTRY %>
  359.     var bEnableSpecificIPs;
  360.     bEnableSpecificIPs = false;
  361.     
  362.     bEnableSpecificIPs = document.forms.pluginForm.IPAddrMode[ 1 ].checked;
  363.     
  364. <% for iIP = 0 to ( rgLen - 1 ) %>
  365.     document.forms.pluginForm.IPAddr<%= iIP %>.disabled = ! bEnableSpecificIPs;
  366. <% next %>
  367.  
  368.     document.forms.pluginForm.portNumber.disabled = ! document.forms.pluginForm.Port[1].checked;
  369.     <% jsCATCH %>
  370. }
  371.  
  372. ///////////////////////////////////////////////////////////////////////////
  373. function ToggleSpecifiedIPAddress( obj, bSimulated )
  374. {
  375.     <% jsTRY %>
  376.     if( ! obj )
  377.     {
  378.         return;
  379.     }
  380.     
  381.     if( obj.disabled )
  382.     {
  383.         return;
  384.     }
  385.         
  386.     if( bSimulated )
  387.     {
  388.         obj.checked = ! obj.checked;
  389.     }
  390.     <% jsCATCH %>
  391. }
  392. -->
  393. </script>
  394. </head>
  395. <body onload="JavaScript:SetControlStates();" class="pluginBody" oncontextmenu="JavaScript:event.cancelBubble=true;return false;">
  396. <% DrawPluginBanner %>
  397. <table width=<%= Server.HTMLEncode( STDTABLEWIDTH ) %> >
  398. <tr>
  399.     <td valign=top>
  400.     
  401.         <% WriteStdPluginForm %>
  402.  
  403.         <p>         
  404.         <table cellpadding=0 cellspacing=0 class="propgroupbox" width="80%">
  405.         <caption align="left" class="pluginGroupHeader"><%= Server.HTMLEncode( L_IPADDRESSES_TEXT ) %></caption>
  406.             <tr>
  407.                 <td width=10> </td>
  408.                 <td><% dwTabIndex = dwTabIndex + 1 %>
  409.                     <input 
  410.                         type="radio" 
  411.                         name="IPAddrMode" 
  412.                         value="listenAll" 
  413.                         onClick="JavaScript:ToggleIPAddressMode( 0 );"
  414.                         tabindex=<%= dwTabIndex %>
  415.                         id="allIP" 
  416.                     <% if bDebugAllowAll then %>
  417.                         checked
  418.                     <% end if %> > <label for="allIP" class="defaultcursor"><% RenderWithErrorCheck Server.HTMLEncode( L_ALLOWALLIPADDRS_TEXT ), "AllIP" %></label>
  419.                 </td>                
  420.             </tr>
  421.             <tr>
  422.                 <td width=10> </td>
  423.                 <td><% dwTabIndex = dwTabIndex + 1 %>
  424.                     <input 
  425.                         type="radio" 
  426.                         name="IPAddrMode" 
  427.                         value="listenSelected" 
  428.                         onClick="JavaScript:ToggleIPAddressMode( 1 );"
  429.                         tabindex=<%= dwTabIndex %>
  430.                         id="selectedIP" 
  431.                     <% if not bDebugAllowAll then %>
  432.                         checked
  433.                     <% end if %> > <label for="selectedIP" class="defaultcursor"><% RenderWithErrorCheck Server.HTMLEncode( L_ALLOWSELECTEDADDRS_TEXT ), "SelectedIP" %></label>
  434.                 </td>
  435.             </tr>
  436.             <tr>
  437.                 <td width=10> </td>
  438.                 <td> 
  439.                     <table border=0>
  440.                         <tr>
  441.                             <td width=30> </td>
  442.                             <td width=300 bgcolor="#FFFFFF">
  443.                                 <table width=100% border=1 bordercolor="<%= Server.HTMLEncode( colorDialogDark ) %>">
  444.                                 <tr>
  445.                                 <td>
  446.                                 <div class=normal>
  447.                                 <%
  448.                                 Dim rgAddresses
  449.                                 Dim eachAddr
  450.                                 Dim availAddr
  451.                                 Dim boundAddr
  452.                                 Dim szIPAddress
  453.                                                                 
  454.                                 i = 0
  455.                                 eachElement = 0
  456.                                 if( 0 <> rgLen ) then
  457.                                     for each availAddr in rgAvailIPAddrs
  458.     
  459.                                         %><% dwTabIndex = dwTabIndex + 1 %>
  460.                                     <input 
  461.                                         type="checkbox" 
  462.                                         name="IPAddr<%= i %>" 
  463.                                         value="on" 
  464.                                         tabindex=<%= dwTabIndex %> <%
  465.  
  466.                                         for each boundAddr in rgBoundIPAddrs
  467.                                             if availAddr = boundAddr then
  468.                                                 Response.Write( " checked " )
  469.                                                 exit for
  470.                                             end if
  471.                                         next
  472.                                         
  473.                                         %> > <%
  474.                                         %><span onClick="JavaScript:ToggleSpecifiedIPAddress( document.forms.pluginForm.IPAddr<%= i %>, true );" class="defaultcursor"><%= availAddr %></span><%
  475.                                         if( 0 < i ) then
  476.                                             Response.Write( vbNewLine )
  477.                                         end if
  478.                                         
  479.                                         i = i + 1
  480.                                         %><br><%
  481.                                     next
  482.                                     %><input type="hidden" name="numIPAddrs" value="<%= rgLen %>"><%
  483.                                 end if
  484.                                 %>
  485.                                 </div>
  486.                                 </td>
  487.                                 </tr>
  488.                                 </table>
  489.                             </td>
  490.                             <td width=10> </td>
  491.                         </tr>
  492.                     </table>
  493.                 </td>
  494.             </tr>
  495.         </table>
  496.  
  497.         <br>
  498.         
  499.         <table cellpadding=0 cellspacing=0 class="propgroupbox" width="80%">
  500.         <caption align="left" class="pluginGroupHeader"><%= Server.HTMLEncode( L_PORTSELECTION_TEXT ) %></caption>
  501.             <tr>
  502.                 <td width=10> </td>
  503.                 <td><% dwTabIndex = dwTabIndex + 1 %>
  504.                     <input 
  505.                         type="radio" 
  506.                         name="Port" 
  507.                         value="Default" 
  508.                         onClick="JavaScript:TogglePortRadioButtons( 0 );"
  509.                         onChange="JavaScript:IsValidEntry();"
  510.                         tabindex=<%= dwTabIndex %> 
  511.                         id="defaultPort" <%
  512.                     if ( bUsesDefaultPort ) then %> checked <%
  513.                     end if %> onClick="JavaScript:TogglePortRadioButtons( 0 );" > <label for="defaultPort" class="defaultcursor"><%= Server.HTMLEncode( L_USEDEFAULTPORT_TEXT ) %> ( <%= CStr( dwDefaultPort ) %> )</label>
  514.                 </td>
  515.             </tr>
  516.  
  517.             <tr>
  518.                 <td width=10> </td>
  519.                 <td><% dwTabIndex = dwTabIndex + 1 %>
  520.                     <input 
  521.                         type="radio" 
  522.                         name="Port" 
  523.                         value="Other" 
  524.                         onClick="JavaScript:TogglePortRadioButtons( 1 );"
  525.                         tabindex=<%= dwTabIndex %> 
  526.                         id="customPort" <%
  527.                     if ( not bUsesDefaultPort) then %> checked <%
  528.                     end if %> > <label for="customPort" class="defaultcursor"><% RenderWithErrorCheck Server.HTMLEncode( L_USEOTHERPORTCOLON_TEXT ) & "<br>", "Port" %></label>
  529.                 </td>
  530.             </tr>
  531.  
  532.             <tr>
  533.                 <td width=10> </td>
  534.                 <td>
  535.                     <table width=100% border=0>
  536.                         <tr>
  537.                             <td width=30> </td>
  538.                             <td><% dwTabIndex = dwTabIndex + 1 %>
  539.                                 <input 
  540.                                     type="text" 
  541.                                     name="portNumber" 
  542.                                     size=6 
  543.                                     maxlength="5"
  544.                                     tabindex=<%= dwTabIndex %> 
  545.                                     value="<%= Server.HTMLEncode( g_objPluginAdmin.Port ) %>" 
  546.                                     onKeyUp="JavaScript:TogglePortRadioButtons( 1 );"
  547.                                     onChange="JavaScript:TogglePortRadioButtons( 1 );"
  548.                                     onPaste="JavaScript:TogglePortRadioButtons( 1 );">
  549.                                     <br>
  550.                             </td>
  551.                         </tr>
  552.                     </table>
  553.                 </td>
  554.             </tr>
  555.         </table>
  556.     </td>
  557. </tr>
  558. <tr>
  559.     <td>
  560.         <tr>
  561.             <td> </td>
  562.         </tr>
  563.         <tr>
  564.             <td valign=bottom><% dwTabIndex = dwTabIndex + 1 %>
  565.                 <input type="submit" id="ok" align="baseline" tabIndex=<%= dwTabIndex %> value="<%= Server.HTMLEncode( L_OKAYBUTTON_TEXT ) %>"> 
  566.                 <% dwTabIndex = dwTabIndex + 1 %>
  567.                 <input type="button" id="cancel" align="baseline" name="cancel" onclick="JavaScript:Cancel()" tabIndex=<%= dwTabIndex %> value="<%= Server.HTMLEncode( L_CANCELBUTTONSPACED_TEXT ) %>"> 
  568.                 <% dwTabIndex = dwTabIndex + 1 %>
  569.                 <input type="button" id="help" align="baseline" name="help" onclick="JavaScript:DoPluginHelp( '<% 
  570.                 if( 0 = strcomp( "HTTP", szProtocolName, vbTextCompare ) ) then 
  571.                     Response.Write( H_HTTPCONTROLPROTHELPTOPIC )
  572.                 elseif( 0 = strcomp( "RTSP", szProtocolName, vbTextCompare ) ) then 
  573.                     Response.Write( H_RTSPCONTROLPROTHELPTOPIC )
  574.                 elseif( 0 = strcomp( "MMS", szProtocolName, vbTextCompare ) ) then 
  575.                     Response.Write( H_MMSCONTROLPROTHELPTOPIC )
  576.                 else
  577.                     Response.Write( H_MMSCONTROLPROTHELPTOPIC )
  578.                 end if
  579.                 %>' )" value="<%= Server.HTMLEncode( L_HELPBUTTONSPACED_TEXT ) %>" tabindex=<%= dwTabIndex %>>
  580.             </td>
  581.         </tr>
  582.     </td>
  583. </tr>
  584. </form>
  585. </table>
  586. <% 
  587. AlertUserWithPopupErrorDialog
  588. OnErrorGoBack 
  589. DrawStdFooter
  590. %>
  591. </body>
  592. </html>
  593. <%
  594. LatchCurrentPage "plugins/ControlProtocolAdmin.asp", qs
  595. EndErrorHandling "ControlProtocolAdmin.asp" 
  596.  
  597. on error resume next
  598. PluginsASPCleanup
  599. %>
  600.